Chris Pollett > Old Classes >
CS174

( Print View )

Student Corner:
  [Grades Sec1]

  [Submit Sec1]

  [Class Sign Up Sec1]

  [
Lecture Notes]
  [Discussion Board]

Course Info:
  [Texts & Links]
  [Topics/Outcomes]
  [Outcomes Matrix]
  [Grading]
  [HW Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Additional Policies]
  [Announcements]

HWs and Quizzes:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5][Quizzes]

Practice Exams:
  [Mid1]  [Final]

                           












HW#4 --- last modified February 17 2019 19:28:57..

Solution set.

Due date: Nov 22

Files to be submitted:
  Hw4.zip

Purpose: To make your own REST web service, to gain experience working with XML, JSON.

Related Course Outcomes:

LO2 -- Write schemas, DTDs, and style sheets for XML documents.

LO4 -- Write client-side scripts that validate HTML forms.

LO5 -- Develop and deploy web applications that involve components, web services, and databases.

Specification:

Development of this homework should be done using git for version control and no more than 100 lines between git commits. Also, to receive any credit the time between commits needs to be sufficient that a person could have typed the changes between commits in. Split the assignment into Issue/Bugs. List these in a readme.txt file in your homework folder. In this file also include the names and IDs of all group members and who was responsible for what so it can be checked with git blame.

Fortune-telling and computational devices have a long history. Some devices such as the Magic 8-Ball introduced in 1946 provides three-bits of wisdom per query. The Unix fortune command has been around since the late 1970s. For this assignment, you are tasked with updating fortune-telling to the Web 2.0 era. First you should create a new XML language for storing a set of fortunes in a document. I want you to give both an XML DTD and an XML Schema to do this. I want you to use a tool like Oxygen XML Editor (first month free) to make sure your DTD and Schema validate. Then I want you to create some sample documents in your language. The base element in your language should be fortunes and it should be able to contain zero or more item's. Each item must contain a text tag, and may optionally contain a genre tag, a rating (Family, PG-13, etc), an author tag, and a source tag. At least one element should have a required attribute.

In additional to your XML language and test documents, I want you to write a CSS for your new language and an XSLT stylesheet for your language. I want at least one of your test documents to link to the CSS document and at least one to link to the XSLT stylesheet. In both cases, the document viewed in a browser should look reasonably aesthetic.

Next I want you to create your own rest-based web service in PHP for retrieving fortunes. You cannot assume anything about where the grader will be testing this service. You can assume the grader will test out the service by trying different urls of the form:

url_grader_is_grading_from/index.php?num=XXX&genre=XXX&rating=XXX&source=XXX&format=XXX

Here num is the number of fortunes desired, format is either XML or JSON, genre, rating, and source correspond to your languages XML languages tags and are optional arguments. If XML is selected then the output should be in the XML language you created. The source argument can take values internal, external, or all and defaults to all if not present. If it is internal, your script should make use of some fortunes you created. If it is external I want you to make a curl or multi-curl request to http://pollett.org/fortune/ to get your fortunes. The option all should use both sources.

The last thing I want you to do for this assignment is to make a simple html page fortune.html associated with an javascript. This page is not allowed to make use of PHP. On the page you should have a single button, which when clicked makes an AJAX request for 5 fortunes from your web-service. It then displays these fortunes nicely below the button in a div tag. The whole page is not allowed to be reloaded only the contents of the div tag should change each time the button is clicked.

Point Breakdown

To receive any credit project was developed as described using git for version control and has a readme.txt as described
XML DTD and schema as described and validate (1pt each) 2pts
Validating example XML documents in your language 1pt
CSS and XSLT stylesheets which are testable from your example documents (1pt each) 2pts
Fortune web-service works overall as described (num, genre, rating arguments work, code is not hard-coded to any url location). 2pts
source argument to web-service works and uses curl/multi-curl 1pt
format argument of web-service works as described. 1pt
fortune.html as described and whose button invokes an external Javascript to make AJAX calls to get fortunes as per the spec. 1pt
Total10pts